Any identifier that is not a syntactic keyword (see
section ) may be used as a variable.variable A variable may name a
location where a value can be stored. A variable that does so is said
to be bound to the location. The set of all visible
bindingsbinding in effect at some point in a program is
known as the environment in effect at that point. The value
stored in the location to which a variable is bound is called the
variable's value. By abuse of terminology, the variable is sometimes
said to name the value or to be bound to the value. This is not quite
accurate, but confusion rarely results from this practice.
Define ``assigned'' and ``unassigned'' perhaps?
In programs without side effects, one can safely pretend that the variables are bound directly to the arguments. Or: In programs without set!, one can safely pretend that the variable is bound directly to the value.
Certain expression types are used to create new locations and to
bind variables to those locations. The most fundamental of these binding constructsbinding construct is the
, because all other binding constructs
can be explained in terms of s. The other binding
constructs are let, let*, letrec, and do
expressions (see sections ,
, and
).
Like Algol and Pascal, and unlike most other dialects of Lisp
except for Common Lisp, Scheme is a statically scoped language with
block structure. To each place where a variable is bound in a program
there corresponds a region of the program text within which
the binding is effective. The region is determined by the particular
binding construct that establishes the binding; if the binding is
established by a , for example, then its region
is the entire . Every reference to or assignment of a
variable refers to the binding of the variable that established the
innermost of the regions containing the use. If there is no binding of
the variable whose region contains the use, then the use refers to the
binding for the variable in the top level environment, if any
(section ); if there is no binding for the identifier,
it is said to be unbound.bound
Mention that some implementations have multiple top level environments?
Pitman sez: needs elaboration in case of (let ...)
Pitman asks: say something about vars created after scheme starts? (define x 3) (define (f) x) (define (g) y) (define y 4) Clinger replies: The language was explicitly designed to permit a view in which no variables are created after Scheme starts. In files, you can scan out the definitions beforehand. I think we're agreed on the principle that interactive use should approximate that behavior as closely as possible, though we don't yet agree on which programming environment provides the best approximation.